package www.openteam.com.adapter.qualityCntrl;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import www.openteam.com.R;
import www.openteam.com.bean.IPQCMsg01;

/**
 * Created by OT on 2018-01-09.
 */

public class IPQCAdapter01 extends RecyclerView.Adapter<IPQCAdapter01.ViewHolder> {

    Context context;
    List<IPQCMsg01.DataBeanX.DataBean> data01 = new ArrayList<>();
    OnLongClickListener onLongClickListener;

    public IPQCAdapter01(Context context) {
        this.context = context;
    }

    public void setOnLongClickListener01(OnLongClickListener onLongClickListener) {
        this.onLongClickListener = onLongClickListener;
    }

    public void setData01(List<IPQCMsg01.DataBeanX.DataBean> data01) {
        this.data01 = data01;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_ipqc_01, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position) {
        IPQCMsg01.DataBeanX.DataBean dataBean = data01.get(position);
        holder.ipqc01Produceno.setText(dataBean.getProduceno());
        holder.ipqc01Groupname.setText(dataBean.getGroupname());
        holder.ipqc01Custcode.setText(dataBean.getCustcode());
        holder.ipqc01Custname.setText(dataBean.getCustname());
        holder.ipqc01Rdsno.setText(dataBean.getRdsno());
        holder.ipqc01PartId.setText(dataBean.getPartId());
        holder.ipqc01Allcount.setText(dataBean.getAllcount() + "");
        holder.ipqc01Prodcode.setText(dataBean.getProdcode());
        holder.ipqc01Recivercount.setText(dataBean.getFBackCount() + "");
        holder.ipqc01Prodname.setText(dataBean.getProdname());
        holder.ipqc01Aproduce.setText(dataBean.getAprocedure());
        holder.ipqc01Aproducename.setText(dataBean.getProcname());

//        if (item.getStatusn().equals("已审核")) {
//            ischeckList.add(true);
        holder.ipqc01Parent.setBackgroundColor(context.getResources().getColor(R.color.green));
//        } else  {
//            ischeckList.add(false);
//            viewHolder.cardView.setCardBackgroundColor(context.getResources().getColor(R.color.green));
//        }
        holder.ipqc01Parent.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (onLongClickListener != null) {
                    onLongClickListener.onLongClick(position);
                }
                return false;
            }
        });
    }

    @Override
    public int getItemCount() {
        return data01.size();
    }


    static

    public class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.ipqc01_Produceno)
        TextView ipqc01Produceno;
        @Bind(R.id.ipqc01_groupname)
        TextView ipqc01Groupname;
        @Bind(R.id.ipqc01_Custcode)
        TextView ipqc01Custcode;
        @Bind(R.id.ipqc01_Custname)
        TextView ipqc01Custname;
        @Bind(R.id.ipqc01_Rdsno)
        TextView ipqc01Rdsno;
        @Bind(R.id.ipqc01_PartId)
        TextView ipqc01PartId;
        @Bind(R.id.ipqc01_allcount)
        TextView ipqc01Allcount;
        @Bind(R.id.ipqc01_Prodcode)
        TextView ipqc01Prodcode;
        @Bind(R.id.ipqc01_Recivercount)
        TextView ipqc01Recivercount;
        @Bind(R.id.ipqc01_Prodname)
        TextView ipqc01Prodname;
        @Bind(R.id.ipqc01_aproduce)
        TextView ipqc01Aproduce;
        @Bind(R.id.ipqc01_aproducename)
        TextView ipqc01Aproducename;
        @Bind(R.id.ipqc01_parent)
        LinearLayout ipqc01Parent;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }

    public interface OnLongClickListener {
        void onLongClick(int postion);
    }

}
